<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 定义一个json数据
        var sJson = '{\
        "name": "tom",\
        "age": 18,\
        "hobby": ["study", "shopping", "singing"],\
        "school": {"name": "XBMZ", "location": "GS"}\
        }';
        // 将json数据转为JavaScript对象
        var oJson = JSON.parse(sJson);
        alert(oJson.name);
        alert(oJson.hobby[0]);
        alert(oJson.school.name);
        alert(oJson.school.location);
    </script>
</head>
<body>
    
</body>
</html>